package com.jiangcheng.demo.utils;


import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.jiangcheng.demo.entity.User;
import org.springframework.stereotype.Component;

@Component
public class TokenUtil {

    public static String getToken(User user){

        System.out.println("生成token:" + user);
        String token = JWT.create().withAudience(Integer.toString(user.getId()))
                .sign(Algorithm.HMAC256(user.getPassword()));

        return token;
    }
}
